<?php
$playerInfos = array();

echo '<planets>';
foreach (U1_Player::getInstanceDb()->query(
	'SELECT planet.id as id, galaxy, system, position, pseudo, ref_user, name, race
	FROM planet
	LEFT JOIN user ON ref_user = user.id',
	PDO::FETCH_OBJ
) as $planet)
{
	echo '<planet id="'.$planet->id.'" ref-user="'.$planet->ref_user.'">
		<name>'.$planet->name.'</name>
		<coordinates>
			<galaxy>'.$planet->galaxy.'</galaxy>
			<system>'.$planet->system.'</system>
			<position>'.$planet->position.'</position>
		</coordinates>
	</planet>';

	if ($planet->ref_user)
		$playerInfos[$planet->ref_user] = array($planet->pseudo, $planet->race);
}
echo '</planets>
<players>';
foreach ($playerInfos as $id => $infos)
	echo '<player id="'.$id.'" race="'.$infos[1].'">'.$infos[0].'</player>';
echo '</players>';